package cloud.xiguapi.ubas.controller;

import cloud.xiguapi.ubas.common.ApiResult;
import cloud.xiguapi.ubas.common.Pager;
import cloud.xiguapi.ubas.entity.BloomUV;
import cloud.xiguapi.ubas.service.impl.BloomUVServiceImpl;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

import static cloud.xiguapi.ubas.constant.FilenameConstant.USER_BEHAVIOR_CSV;
import static cloud.xiguapi.ubas.constant.GlobalConstant.DEV;

/**
 * 基于Bloom Filter的UV统计Controller
 *
 * @author 大大大西西瓜皮🍉
 * date: 2021-5-20 下午 04:19
 * desc:
 */
@RestController
@RequestMapping("/bloom-uv")
public class BloomUVController {

    @Resource(name = "bloomUVService")
    private BloomUVServiceImpl bloomUVService;

    @GetMapping("/analysis")
    public ApiResult<Object> analysis() {
        return bloomUVService.analysis(DEV.getPrefix() + USER_BEHAVIOR_CSV.getFilename());
    }

    @GetMapping("/select")
    public ApiResult<Pager<BloomUV>> selectPage() {
        return bloomUVService.select();
    }
}
